/* c成都与上海价格对比*--*/

function echarts_7(data1,data2){
    var myChart = echarts.init(document.getElementById('echart7'));

//数据处理

    var year = new Set(); //年限表
    for (var i = 0 ;i < data1.length ;i++){//获取年限表
        year.add(data1[i].year)

    }
    year = Array.from(year);
    city = ['成都','上海']
    series = [];
    for (var i = 0;i < 2 ;++i)// 初始化series集合
        series[i] = {
                name: city[i],//城市
                type: 'line',
        
                data: [0,0,0,0,0], //数据项 data_y
        
                itemStyle: {
                    normal: {
                        color: '#2f89cf',
                        opacity: 1,
        
                        barBorderRadius: 5,
                    }
                }
                ['#37A2DA', '#32C5E9', '#67E0E3', '#9FE6B8', '#FFDB5C','#ff9f7f', '#fb7293', '#E062AE', '#E690D1', '#e7bcf3', '#9d96f5', '#8378EA', '#96BFFF'],
            }
    var price1 = [] , price2 = [];
    for(var i = 0 ;i<data1.length;++i )
            price1[i] = data1[i].yearavgeprice;

            for(var i = 0 ;i<data2.length;++i )
            price2[i] = data2[i].yearavgeprice;
            

            series[0].data = price1 
            series[1].data = price2


    // ---------------xuanran--------------------------*/


    option = {
        //  backgroundColor: '#00265f',
        color: ['#ff0000','#00ff00', '#0000ff', '#d48265', '#91c7ae','#749f83',  '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        legend: {
            data: ['成都','上海'],
            align: 'right',
            // right: '40%',
            top: '0%',
            textStyle: {
                color: "#fff",
                fontSize: '16',

            },

            itemGap: 35
        },
        grid: {
            left: '0%',
            top: '40px',
            right: '0%',
            bottom: '2%',
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            data: year,
            axisLine: {
                show: true,
                lineStyle: {
                    color: "rgba(255,255,255,.1)",
                    width: 1,
                    type: "solid"
                },
            },
            axisTick: {
                show: false,
            },
            axisLabel: {
                interval: 0,
                // rotate:50,
                show: true,
                splitNumber: 15,
                textStyle: {
                    color: "rgba(255,255,255,.6)",
                    fontSize: '16',
                },
            },
        }],
        yAxis: [{
            type: 'value',
            axisLabel: {
                //formatter: '{value} %'
                show: true,
                textStyle: {
                    color: "rgba(255,255,255,.6)",
                    fontSize: '16',
                },
            },
            axisTick: {
                show: false,
            },
            axisLine: {
                show: true,
                lineStyle: {
                    color: "rgba(255,255,255,.1	)",
                    width: 1,
                    type: "solid"
                },
            },
            splitLine: {
                lineStyle: {
                    color: "rgba(255,255,255,.1)",
                }
            }
        }],
        series: series //传入数据簇
            //serise 数组里面的对象
    // {
    //     name: ' ',//城市
    //     type: 'line',

    //     data: [0, 0, 0, 0, 0, 0, 0, 13, 8, 5, 6, 9], //数据项 data_y

    //     itemStyle: {
    //         normal: {
    //             color: '#2f89cf',
    //             opacity: 1,

    //             barBorderRadius: 5,
    //         }
    //     }
    // }

    };


    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    });
}

